﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControl : MonoBehaviour {

    private PlayerFSMSystem fsm;

    public void SetTransition(Transition t) { fsm.PerformTransition(t); }

    private void Start()
    {
        MakeFSM();
    }

    private void Update()
    {
        fsm.CurrentState.Reason(gameObject);
        fsm.CurrentState.Act(gameObject);
    }

    private void MakeFSM()
    {
        Debug.Log("加入transition");
        NoItm_IdleState noItm_IdleState = new NoItm_IdleState();
        noItm_IdleState.AddTransition(Transition.IsWalk, StateID.WalkID);

        NoItm_RunState noItm_RunState = new NoItm_RunState();
        noItm_RunState.AddTransition(Transition.IsWalk, StateID.WalkID);

        NoItm_WalkState noItm_WalkState = new NoItm_WalkState();
        noItm_WalkState.AddTransition(Transition.isIdle, StateID.IdleID);
        noItm_WalkState.AddTransition(Transition.IsRun, StateID.RunID);

        fsm = new PlayerFSMSystem();
        fsm.AddState(noItm_IdleState);
        fsm.AddState(noItm_RunState);
        fsm.AddState(noItm_WalkState);

    }

}
